; basqet.nsi
;
; This script is based on example2.nsi, but it remember the directory, 
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install Basqet into a directory that the user selects,

;--------------------------------

; The name of the installer
Name "Basqet"

; The file to write
OutFile "Basqet-installer-0.2.0.exe"

; The default installation directory
InstallDir $PROGRAMFILES\Basqet

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Basqet" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Basqet"

  SectionIn RO
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File "mingwm10.dll"
  File "QtCore4.dll"
  File "QtGui4.dll"
  File "QtScript4.dll"
  File "QtXml4.dll"
  File "QtXmlPatterns4.dll"
  File "basqet.exe"
  File "libgcc_s_dw2-1.dll"

  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\Basqet "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Basqet" "DisplayName" "Basqet"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Basqet" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Basqet" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Basqet" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\Basqet"
  CreateShortCut "$SMPROGRAMS\Basqet\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Basqet\Basqet.lnk" "$INSTDIR\basqet.exe" "" "$INSTDIR\basqet.exe" 0

SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Basqet"
  DeleteRegKey HKLM SOFTWARE\Basqet

  ; Remove files and uninstaller
  Delete $INSTDIR\*.*
  Delete $INSTDIR\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\Basqet\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\Basqet"
  RMDir "$INSTDIR"

SectionEnd
